#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;
/*
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "a*") → true
isMatch("aa", ".*") → true
isMatch("ab", ".*") → true
isMatch("aab", "c*a*b") → true
*/

class Solution {
    public:
        bool isMatch(const char *s, const char *p) {
            bool result = false;
            if (*p == '\0') return *s == '\0';
            
            if (*(p+1) != '*') {
                return ((*p == *s) || (*p == '.' && *s != '\0')) && isMatch(s+1, p+1);
            }

            while ((*s == *p) || (*p == '.' && *s != '\0')) {
                if (isMatch(s, p+2)) return true;
                s++;
            }
            return isMatch(s, p+2);
        }
};

int main(int argc, char **argv)
{
    Solution mySolution;
    bool result;
 
    cout << "-----------------Test 1--------------------" << endl;
    result = mySolution.isMatch("aa", "a");
    cout << result << endl;

    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
